import time

from selenium import webdriver
from selenium.webdriver.common.by import By


class TestDemo:
    def setup_class(self):
        self.driver = webdriver.Chrome()
        self.driver.implicitly_wait(3)
    def teardown_class(self):
        self.driver.quit()


    def test_pet(self):
        self.driver.get("https://petclinic.k8s.hogwarts.ceshiren.com/#!/welcome")
       # 打开register，输入信息
        self.driver.find_element(By.CLASS_NAME,"dropdown-toggle").click()
        self.driver.find_element(By.CSS_SELECTOR,".glyphicon.glyphicon-plus").click()
        self.driver.find_elements(By.CSS_SELECTOR,".form-group>input")[0].send_keys("guo")
        self.driver.find_elements(By.CSS_SELECTOR,".form-group>input")[1].send_keys("yirou")
        self.driver.find_elements(By.CSS_SELECTOR,".form-group>input")[2].send_keys("河北")
        self.driver.find_elements(By.CSS_SELECTOR,".form-group>input")[3].send_keys("张家口")
        self.driver.find_elements(By.CSS_SELECTOR,".form-group>input")[4].send_keys(987654)
        self.driver.find_element(By.CSS_SELECTOR,".btn.btn-default").click()
        time.sleep(1)
        #搜索最新输入的信息
        self.driver.find_element(By.CSS_SELECTOR,".form-group>input").click()
        self.driver.find_element(By.CSS_SELECTOR,".form-group>input").send_keys("guo")
        # 点击最新输入的信息
        self.driver.find_elements(By.CSS_SELECTOR,".ng-scope>td>a")[0].click()
        time.sleep(1)
        #输入宠物信息
        self.driver.find_elements(By.CSS_SELECTOR, ".btn.btn-default")[1].click()
        time.sleep(1)
        self.driver.find_elements(By.CSS_SELECTOR, ".col-sm-6>input")[0].send_keys("小白")
        self.driver.find_elements(By.CSS_SELECTOR, ".col-sm-6>input")[1].send_keys("002022/11/11")
        self.driver.find_element(By.CSS_SELECTOR, ".col-sm-6>select").click()
        self.driver.find_elements(By.CSS_SELECTOR, ".col-sm-6>select>option")[2].click()
        time.sleep(1)
        self.driver.find_element(By.CSS_SELECTOR, ".btn.btn-default").click()
        time.sleep(1)
        self.driver.find_element(By.CSS_SELECTOR, ".form-group>input").click()
        self.driver.find_element(By.CSS_SELECTOR, ".form-group>input").send_keys("guo")
        self.driver.find_elements(By.CSS_SELECTOR, ".ng-scope>td>a")[0].click()
        time.sleep(1)
        web_element = self.driver.find_elements(By.CSS_SELECTOR, ".dl-horizontal>dd>a")[0]
        assert "小白" in web_element.text